// Ionic Starter App

// angular.module is a global place for creating, registering and retrieving Angular modules
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
// the 2nd parameter is an array of 'requires'
// 'starter.controllers' is found in controllers.js
angular.module('starter', ['ionic','ngCordova','starter.controllers','starter.services'])

.run(function($http,$rootScope,$state,$ionicPlatform) {

  $ionicPlatform.ready(function() {
        // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
        // for form inputs)
        if (window.cordova && window.cordova.plugins.Keyboard) {
          cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
          cordova.plugins.Keyboard.disableScroll(true);
        }
        if (window.StatusBar) {
          // org.apache.cordova.statusbar required
          StatusBar.styleDefault();
        }
   });
})

.config(function($stateProvider, $urlRouterProvider) {
  $stateProvider

  .state('app', {
    url: '/app',
    abstract: true,
    templateUrl: 'templates/menu.html',
    controller: 'AppCtrl'
  })

  .state('app.card', {
    url: '/card',
    views: {
      'menuContent': {
        templateUrl: 'templates/card.html',
        controller: 'CardCtrl'
      }
    }
  })

  .state('app.detail',{
      url:'/card/detail/:cardId',
      views: {
          'menuContent': {
              templateUrl: 'templates/cardDetail.html',
              controller: 'CardDetailCtrl'
          }
      }
  })

  .state('app.favorite',{
      url:'/favorite',
      views: {
          'menuContent': {
              templateUrl: 'templates/favorite.html',
              controller: 'FavoriteCtrl'
          }
      }
  })

  .state('app.setting',{
      url:'/setting',
      views: {
          'menuContent': {
              templateUrl: 'templates/setting.html',
              controller: 'SettingCtrl'
          }
      }
  })

  .state('app.about',{
      url:'/about',
      views: {
          'menuContent': {
              templateUrl: 'templates/about.html'
          }
      }
  })

  .state('app.map',{
      url:'/map',
      views: {
          'menuContent': {
              templateUrl: 'templates/map.html'
          }
      }
  })

  .state('app.item',{
      url:'/item',
      views: {
          'menuContent': {
              templateUrl: 'templates/items.html'
          }
      }
  })

  .state('app.camera',{
      url:'/camera',
      views: {
          'menuContent': {
              templateUrl: 'templates/camera.html'
          }
      }
  })

  // if none of the above states are matched, use this as the fallback
  $urlRouterProvider.otherwise('/app/card');

});
